<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <style>
        .a{
            width: 1200px;
            height: 40px;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="a">
        姓名:
        <el-input v-model="input.name" placeholder="请输入姓名" style="width: 200px;height: 20px;"></el-input>
        科室查询:
        <el-input v-model="input.aa" placeholder="请选择" style="width: 200px;height: 20px;"></el-input>
        <el-button type="primary" icon="el-icon-search"@click="searchSub()">查 询</el-button>

    </div>
    <template>
        <el-table
                :data="subArr"
                border
                style="width: 100%">
            <el-table-column
                    prop="id"
                    label="编号"
                    width="52">
            </el-table-column>
            <el-table-column
                    prop="name"
                    label="患者姓名"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="identity"
                    label="身份证号"
                    width="220">
            </el-table-column>
            <el-table-column
                    prop="age"
                    label="患者年龄"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="telephone"
                    label="手机号码"
                    width="150">
            </el-table-column>
            <el-table-column
                    prop="gender"
                    label="性别"
                    width="150">
            </el-table-column>
            <el-table-column
                    prop="kid"
                    label="科室"
                    width="150">
            </el-table-column>
            <el-table-column
                    prop="state"
                    label="状态"
                    width="130">
            </el-table-column>
            <el-table-column
                    label="操作"
                    width="250">
                <template slot-scope="scope">
                    <el-button type="danger" @click="deleteSubscribe(scope.row.id)">删 除</el-button>
                    <el-button type="primary" @click="showUpdateDialog(scope.row.identity)">审 查</el-button>
                </template>

            </el-table-column>
        </el-table>
        <el-pagination
                @current-change="handleCurrentChange"
                layout="prev, pager, next"
                :total="totalCount">
        </el-pagination>
    </template>
</div>

<script >
    var haha = new Vue({
        el:"#app",
        data:{
            input:{},
            subArr:[],
            totalCount:0,
            dialogFormVisible: false,
            updateDialogFormVisible:false,
            subInfo:{},
            rules:{
                password:[
                    {required:true,message:'请输入账号',trigger:'blur'},
                ],
                name:[
                    {required:true,message:'请输入姓名',trigger:'blur'},
                ],
                age:[
                    {required:true,message:'请输入年龄',trigger:'blur'},
                ],
                time:[
                    {required:true,message:'请选择时间',trigger:'blur'},
                ],
                price:[
                    {required:true,message:'请输入价格',trigger:'blur'},
                ],
                gid:[
                    {required:true,message:'请选择科室',trigger:'blur'},
                ]



            }
        },
        methods:{
            updateSub(){
                $.get("/ssm/sub/update",haha.subInfo,function (backData) {
                    if (backData.code ==1){
                        haha.updateDialogFormVisible = false;
                        haha.$refs["subInfo"].resetFields();
                        haha.$message.success('修改成功');
                        getData(1,10);
                    }else {
                        haha.$message.error('修改失败 请联系管理');
                    }

                })
            },
            showUpdateDialog(identity){
                window.location.href="/ssm/doctor/case.html?identity="+identity

            },
            deleteSubscribe(id){
                haha.$confirm('此操作将永久删除该预约信息, 是否继续?', '温馨提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                    center: true
                }).then(() => {
                   $.get("/ssm/sub/delete/"+id,function (backData) {
                       haha.$message.success(backData.msg);
                       getData(1,10);
                   })
                });

            },
            showAddDialog(){
                haha.dialogFormVisible = true;
            },
            addSub(){
                haha.$refs["subInfo"].validate((valid) => {
                    if(valid){
                        $.post("/ssm/sub/add",haha.subInfo,function (backData) {
                            if (backData.code ==2){
                                haha.dialogFormVisible = false;
                                haha.$refs["subInfo"].resetFields();
                                haha.$message.success('添加成功');
                                getData(1,10);
                            }else {
                                haha.$message.error('添加失败 请联系管理');
                            }
                        });
                    }
                });

            },
            searchSub(){
                getData(1,10);
            },
            handleCurrentChange(val){
                getData(val,10);
            }

        }
    });
    function getData(a, b) {
        haha.input.pageNo=a;
        haha.input.pageCount=b;
        $.post("/ssm/sub/query",haha.input,function (backData) {
            haha.subArr=backData.data.currentData;
            haha.totalCount=backData.data.totalCount;
        })
    }
    getData(1,10);
</script>

</body>
</html>
